<template>
	<view class="p30">
		<view class="radius20 bg-fff p20">
			<view class="color-666 mb20">体检报告 (请上传近3个月的体检报告)</view>
			<z-imgs up ref="report"  @success="report=$event" />
		</view>
		<view class="radius20 bg-fff p20 mt20">
			<view class="color-666 mb20">上传明细</view>
			<u-empty v-if="!list.length" marginTop="100"></u-empty>
			<view class="pt20 pb20 flex row-between" v-for="(item,index) in list" :key="index" @click="lookImg(index)">
				<view class="">{{item.create_time}}更新体检报告</view>
				<view class="fs24 color-999">查看照片</view>
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf bg-fff p30 w-max left0 bottom0">
			<u-button type="warning" ripple @click="submit">提交</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				report: '',
				list: [],
			};
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			this.getList('down')
		},
		methods: {
			lookImg(index) {
				this.$tool.lookImg(this.list.map(e => e.report_path), index)
			},
			submit() {
				if (!this.report) return this.$msg('请上传体检报告')
				this.$request('/master/my/uploadReport', {
					report: this.report
				}).then(res => {
					this.$msg(res.msg)
					this.getList()
					this.$refs.report.list=[]
				})
			},
			getList(e) {
				e == 'down' ? this.page++ : this.page = 1
				this.$request('/master/my/reportLog',{
					page:this.page,
				}).then(res => {
					let list = res.data.data
					e == 'down' ? this.list.push(...list) : this.list = list
				})
			}
		}
	}
</script>

<style lang="scss">

</style>